<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>
<body>
  <div id="app">
    <home></home>
  </div>
  <script>
    let CommonTitle = {
   
      template:`
        <div>
            子组件
            <button @click="biubiubiu">点击传数据</button>
        </div>
      `,
      data(){
        return {
          msg:"我是子组件的数据"
        }
      },
      methods:{
        biubiubiu(){
          this.$emit("piu",this.msg)
          // 组件 实例 上  方法  $emit()  eject
        }
      }
    }
    let Home = {
      template:`
        <div>
          <common-title @piu="fn"></common-title>  
          home页内容  
          {{ msg }}
        </div>
      `,
      data(){
        return {
          msg:"我是父组件的数据"
        }
      },
      methods:{
        fn(msg){
          this.msg = msg;
        }
      },
      components:{
        CommonTitle
      }
    }
    let vm = new Vue({
      el:"#app",
      components:{
        Home
      }
    })
  </script>
</body>
</html>